package com.mflex.WHSmartWhouseAd.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mflex.WHSmartWhouseAd.R;
import com.mflex.WHSmartWhouseAd.model.ResCheckFatherAndSonDto;
import com.mflex.WHSmartWhouseAd.model.WHCompCheckTaskDetails;
import com.xuexiang.xutil.common.StringUtils;

import java.util.List;

public class StockTaskDetaillistAdapter extends BaseAdapter {
    List<ResCheckFatherAndSonDto> items;
    Activity context;

    public StockTaskDetaillistAdapter(Activity context, List<ResCheckFatherAndSonDto> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ResCheckFatherAndSonDto item = items.get(position);
        View view = convertView;
        view = context.getLayoutInflater().inflate(R.layout.item_stock_task_detail_list, null);
        ((TextView) view.findViewById(R.id.txtWHLocName)).setText(item.getWHLOC());
        ((TextView) view.findViewById(R.id.txtBoxNo)).setText(item.getSONID());
        ((TextView) view.findViewById(R.id.txtNumber)).setText(item.getSONQTY());

//        if (StringUtils.equals("已盘点",item.getStatus())) {
//            ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.GREEN);
//        }

        if (StringUtils.equals("2",item.getSTATUS())) {
            ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.GREEN);
        }

        return view;
    }
}